package com.zed.games.repository;

import com.zed.api.domain.currentuser.Account;
import com.zed.api.games.Game;
import com.zed.api.games.ImmutableGameWrapper;

import java.util.Objects;

/**
 * 每个账号对应的开启的游戏
 *
 * @author Zed
 */
class AccountGame {

    private Account account;

    private ImmutableGameWrapper game;

    public AccountGame(Account account, ImmutableGameWrapper game) {
        this.account = Objects.requireNonNull(account, "\"account\" cannot be null");
        this.game = Objects.requireNonNull(game, "\"game\" cannot be null");
    }

    /**
     * 账号
     *
     * @return {@link Account}
     */
    public Account getAccount() {
        return this.account;
    }

    /**
     * 获取游戏
     *
     * @return {@link Game}
     */
    public Game getGame() {
        return this.game;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AccountGame that = (AccountGame) o;
        return Objects.equals(account.getId(), that.account.getId()) && Objects.equals(game.getId(), that.game.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(account.getId(), game.getId());
    }
}
